% Remember to use the lgrind style

\Head{}
\File{agmemread.c}{2013}{3}{6}{15:39}{893}
\L{\LB{\K{typedef}_\K{struct}_\{}}
\L{\LB{}\Tab{4}{\V{const}_\K{char}_*\V{data};}}
\L{\LB{}\Tab{4}{\K{int}_\V{len};}}
\L{\LB{}\Tab{4}{\K{int}_\V{cur};}}
\L{\LB{\}_\V{rdr\_t};}}
\L{\LB{}}
\index{memiofread}\Proc{memiofread}\L{\LB{\K{static}_\K{int}_\V{memiofread}(\K{void}_*\V{chan},_\K{char}_*\V{buf},_\K{int}_\V{bufsize})}}
\L{\LB{\{}}
\L{\LB{}\Tab{4}{\V{const}_\K{char}_*\V{ptr};}}
\L{\LB{}\Tab{4}{\K{char}_*\V{optr};}}
\L{\LB{}\Tab{4}{\K{char}_\V{c};}}
\L{\LB{}\Tab{4}{\K{int}_\V{l};}}
\L{\LB{}\Tab{4}{\V{rdr\_t}_*\V{s};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\K{if}_(\V{bufsize}_==_\N{0})_\K{return}_\N{0};}}
\L{\LB{}\Tab{4}{\V{s}_=_(\V{rdr\_t}_*)_\V{chan};}}
\L{\LB{}\Tab{4}{\K{if}_(\V{s}\-\!\>\V{cur}_\>=_\V{s}\-\!\>\V{len})}}
\L{\LB{}\Tab{8}{\K{return}_\N{0};}}
\L{\LB{}\Tab{4}{\V{l}_=_\N{0};}}
\L{\LB{}\Tab{4}{\V{ptr}_=_\V{s}\-\!\>\V{data}_+_\V{s}\-\!\>\V{cur};}}
\L{\LB{}\Tab{4}{\V{optr}_=_\V{buf};}}
\L{\LB{}\Tab{4}{\K{do}_\{}}
\L{\LB{}\Tab{8}{*\V{optr}++_=_\V{c}_=_*\V{ptr}++;}}
\L{\LB{}\Tab{8}{\V{l}++;}}
\L{\LB{}\Tab{4}{\}_\K{while}_(\V{c}_\&\&_(\V{c}_!=_\S{}{'}\2n{'}\SE{})_\&\&_(\V{l}_\<_\V{bufsize}));}}
\L{\LB{}\Tab{4}{\V{s}\-\!\>\V{cur}_+=_\V{l};}}
\L{\LB{}\Tab{4}{\K{return}_\V{l};}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{\K{static}_\V{Agiodisc\_t}_\V{memIoDisc}_=_\{\V{memiofread},_\N{0},_\N{0}\};}}
\L{\LB{}}
\index{agmemread}\Proc{agmemread}\L{\LB{\V{Agraph\_t}_*\V{agmemread}(\V{const}_\K{char}_*\V{cp})}}
\L{\LB{\{}}
\L{\LB{}\Tab{4}{\V{rdr\_t}_\V{rdr};}}
\L{\LB{}\Tab{4}{\V{Agdisc\_t}_\V{disc};}}
\L{\LB{}\Tab{4}{\V{Agiodisc\_t}_\V{memIoDisc};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{memIoDisc}.\V{putstr}_=_\V{AgIoDisc}.\V{putstr};}}
\L{\LB{}\Tab{4}{\V{memIoDisc}.\V{flush}_=_\V{AgIoDisc}.\V{flush};}}
\L{\LB{}\Tab{4}{\V{rdr}.\V{data}_=_\V{cp};}}
\L{\LB{}\Tab{4}{\V{rdr}.\V{len}_=_\V{strlen}(\V{cp});}}
\L{\LB{}\Tab{4}{\V{rdr}.\V{cur}_=_\N{0};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{disc}.\V{mem}_=_\V{NULL};}}
\L{\LB{}\Tab{4}{\V{disc}.\V{id}_=_\V{NULL};}}
\L{\LB{}\Tab{4}{\V{disc}.\V{io}_=_\&\V{memIoDisc};}}
\L{\LB{}\Tab{4}{\K{return}_\V{agread}_(\&\V{rdr},_\&\V{disc});}}
\L{\LB{\}}}
